<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2016/9/20
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>线下服务管理页面</title>
    <script type="application/javascript" src="../../js/gtimp3/declaration.js"></script>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [
                {
                    name: "declaration_type",
                    label: "进出口类型",
                    type: "dropdown",
                    data: [["进口", "I"], ["出口", "E"]],
                    op: "eq",
                    minLength: 0
                }, {
                    name: "contract_no",
                    label: "合同协议号"
                }, {
                    name: "businessId",
                    label: "业务编号"
                }, {
                    name: "container_no",
                    label: "集装箱号"
                }, {
                    name: "company_co",
                    label: "收发货人",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "../order-dropdown/company",
                    op: "eq",
                    minLength: 1,
                    keyWordName: "key",
                    success: function (data) {
                        data = data.results;
                        var array = new Array();
                        $.each(data, function (i, n) {
                            array.push([n["text"], n["value"]]);
                        });
                        return array;
                    }
                }, {
                    name: "bl_no",
                    label: "提运单号"
                }, {
                    name: "confirmTime",
                    label: "提交时间起",
                    type: "date",
                    op: "ge"
                }, {
                    name: "confirmTime",
                    label: "提交时间止",
                    type: "date",
                    op: "le"
                }, {
                    name: "customer.name",
                    label: "实际托运人"
                }],
            buttons: {
                custom: [{
                    id: "updatebtn0",
                    value: "提交",
                    click: function () {
                        var id = getSelectedRowById('declarationsDataGrid');
                        if(id == null){
                            return ;
                        }
                        doZhuanGuan(id);
                    }
                }]
            },
            grid: {
                id: "declarationsDataGrid",
                title: "查询结果",
                url: "../business/findSecondSupValidList",
                multiselect: true,
                colModel: [{
                    index: "ID",
                    name: "id",
                    hidden: true
                }, {
                    name: "businessId",
                    label: "业务编号",
                    formatter: function (cellvalue, options, rowObject) {
                        return "<a href=\"javascript:;\" onclick=\"javascript:doEditSingle('"
                            + rowObject.id + "','"
                            + rowObject.declaration_type + "','"
                            + rowObject.enter_page + "',false,'toValid');\">" + cellvalue
                            + "</a>";
                    }
                }, {
                    name: "declaration_type",
                    label: "进出口类型",
                    align: "center",
                    formatter: function (val) {
                        return "E" === val ? "出口" : "进口"
                    }
                },{
                    name: "data_type",
                    sortable: false,
                    width: 80,
                    label: "直/转类型"
                },{
                    name: "container_no",
                    label: "集装箱号"
                }, {
                    name: "bl_no",
                    label: "提运单号"
                }, {
                    name: "contract_no",
                    label: "合同协议号"
                }, {
                    name: "company_name",
                    label: "收发货人"
                }, {
                    name: "customer.name",
                    label: "实际托运人"
                }, {
                    name: "confirmTime",
                    label: "业务提交时间"
                }, {
                    name: "paymentTime",
                    label: "业务支付时间"
                }, {
                    name: "creator",
                    label: "下单人"
                }, {
                    name: "validator.name",
                    width: 60,
                    label: "核实人"
                }, {
                    name: "state",
                    label: "业务状态",
                    formatter: function (cellvalue, options, rowObject) {
                        switch (cellvalue) {
                            case "DS00":
                                return "草稿状态";
                            case "DS01":
                                return "待审核";
                            case "DS02":
                                return "已审核";
                            case "DS03":
                                return "驳回";
                            case "DS04":
                                return "已安排";
                            case "DS05":
                                return "放行";
                            case "DS06":
                                return "初审";
                            case "DS07":
                                return "复审";
                            case "DS08":
                                return "现场递单";
                            case "DS09":
                                return "查验";
                            case "DS10":
                                return "海关放行";
                            case "DS11":
                                return "商检放行";
                            default:
                                return "";
                        }
                    }
                }],
                sortname: "businessId",
                sortorder: "desc",
                ondblClickRow: function (rowid, iRow, iCol, e) {
                    if (rowid) {
                        var rowData = $("#declarationsDataGrid").jqGrid("getRowData", rowid);
                        doEditSingle(rowid, rowData.declaration_type,rowData.enter_page, false, 'toValid');
                    }
                }
            }
        };
        $(document).ready(function () {
            $("#declarationsDataTable").mrdForm(formSetting);
        });

        function doZhuanGuan(declarationId) {
            jw.dialog({
                iframe: "/business/declaration-toZhuanGuanNoQp#"
                + declarationId,
                title: "直航转关互转",
                iframeFetchTitle: false,
                width: 500,
                height: 150
            });
        }

        //选择一条记录
        function getSelectedRowById(gridId) {
            var grid = $("#"+gridId);
            var rowKey = grid.getGridParam("selrow");
            if(!rowKey){
                alert("请选择一条记录");
                return ;
            }

            var selectedIDs = grid.getGridParam("selarrrow");
            if(selectedIDs.length > 1){
                alert("只能选择一条记录");
                return ;
            }

            return selectedIDs[0];
        }
    </script>
</head>
<body>
<div id="declarationsDataTable"></div>
</body>
</html>
